module.exports = (req,res,next)=>{
    const noCheck = [
        '/api/login',
        '/api/register',
        '/login',
        '/register'
    ]
    if(noCheck.includes(req.path)){
        next()
    }else{
        if(!req.session.user){
            res.redirect('/login')
           
        }else{
            next()
        }
    }
    
}